package com.zl.common.exception;

import com.zl.common.enums.resp.IRespEnum;

/**
 * 基础异常.
 */
public class BizException extends RuntimeException {
    
    /** The Constant serialVersionUID. */
    private static final long serialVersionUID = -2856575469726587413L;

    /** 错误结果代码. */
    private String errorCode;

    /** 错误信息. */
    private String errorMessage;

    /**
     * 构造函数.
     *
     * @param errorCode 错误代码
     * @param errorMessage 错误信息
     */
    public BizException(String errorCode, String errorMessage) {
        super(errorMessage);
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }
    
    public BizException(String errorMessage) {
        super(errorMessage);
        this.errorCode = "error";
        this.errorMessage = errorMessage;
    }
    
    /**
     * 构造函数.
     *
     * @param errorCode 错误代码
     * @param errorMessage 错误信息
     * @param throwable the throwable
     */
    public BizException(String errorCode, String errorMessage, Throwable throwable) {
        super(errorMessage, throwable);
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }
    
    
    /**
     * 构造函数.
     *
     * @param errorCode 错误代码
     * @param errorMessage 错误信息
     */
    public BizException(IRespEnum resp) {
        super(resp.getMsg());
        this.errorCode = resp.getCode();
        this.errorMessage = resp.getMsg();
    }
    
    
    public String getErrorCode() {
        return errorCode;
    }
    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }
    
    public String getErrorMessage() {
        return errorMessage;
    }
    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }
}
